package com.baseandroid.config;

public class Api {

    public static boolean isDevelop = false;

    /*----Retrofit must add one "/" after url -----*/
    public static String sServerApiUrl     = "https://apis.qianbao.com/life/";
    public static String sServerTestApiUrl = "http://118.31.48.228:10982/life/";
    public static String sServerPreApiUrl  = "https://pre-apis.qianbao.com/life/";
    public static String sServerRelApiUrl  = "https://apis.qianbao.com/life/";

    /*Loan Url*/
    public static String sLoanApiUrl     = "https://loan.qianbao.com/loan/merchantAuth.do";
    public static String sLoanTestApiUrl = "http://172.28.38.83/loan/merchantAuth.do";
    public static String sLoanPreApiUrl  = "https://loan.qianbao.com/loan/merchantAuth.do";
    public static String sLoanRelApiUrl  = "https://loan.qianbao.com/loan/merchantAuth.do";

    /*Balance Url*/
    public static String sBalanceApiUrl     = "https://apis.qianbao.com/";
    public static String sBalanceTestApiUrl = "https://sit3-apis.qianbao.com/";
    public static String sBalancePreApiUrl  = "https://pre-apis.qianbao.com/";
    public static String sBalanceRelApiUrl  = "https://apis.qianbao.com/";

    /*--Balance analysis Url--*/
    public static String sBalanceH5ApiUrl     = "http://p.qianbaocard.com/bussAnalysis/index.html#/";
    public static String sBalanceH5TestApiUrl = "http://10.10.20.163:8091/#/";
    public static String sBalanceH5PreApiUrl  = "http://p-pre.qianbaocard.org/bussAnalysis/index.html#/";
    public static String sBalanceH5RelApiUrl  = "http://p.qianbaocard.com/bussAnalysis/index.html#/";

    /*--Contract Url--*/
    public static String sContractApiUri     = "http://ajmide-contract.qianbaocard.org/";
    public static String sContractTestApiUri = "http://ajmide-contract-test.qianbaocard.org/";
    public static String sContractPreApiUri  = "http://ajmide-contract-pre.qianbaocard.org/";
    public static String sContractRelApiUri  = "http://ajmide-contract.qianbaocard.org/";

    /*--版本更新文件下载地址--*/
    public static String sUpdateUrl     = "http://sj.qianbaocard.com/sapp/shanghu.apk";
    public static String sUpdateTestUrl = "http://sj.qianbaocard.org/sapp/shanghu.apk";
    public static String sUpdatePreUrl  = "http://sj.qianbaocard.org/sapp/shanghu.apk";
    public static String sUpdateRelUrl  = "http://sj.qianbaocard.com/sapp/shanghu.apk";

    /*UPLOADING*/
    public static       String sUpLoadingUrl        = "http://s.qianbaocard.com/";
    public final static String sUpLoadingDevDoneUri = "http://test.qianbaocard.org/";
    public final static String sUpLoadingPreRelUri  = "http://s.qianbaocard.com/";
    public final static String sUpLoadingRelDoneUri = "http://s.qianbaocard.com/";

    /**
     * 结算规则url
     */
    public static String balanceRuleUrl
            = "http://s.qianbaocard.com/merchant/h5/help_info/offer_help.html";
    /**
     * 对账方法url
     */
    public static String balanceWayUrl
            = "http://s.qianbaocard.com/merchant/h5/help_info/rec_help.html";

    /**
     * 押金H5de url
     */
    public static       String depositH5Url     = "http://p.qianbaocard.com/posAeposit/index.html#/";
    public final static String depositTestH5Url = "http://pos-test.qianbaocard.org/#/";
    public final static String depositPreH5Url  = "http://p-pre.qianbaocard.org/posAeposit/index.html#/";
    public final static String depositProH5Url  = "http://p.qianbaocard.com/posAeposit/index.html#/";

    /**
     * environment切换环境：
     * 1：测试环境；
     * 2：预发布环境；
     * 3: 线上环境;
     */
    public enum AppEnviron {
        DEV_TEST_ENV(1),
        REL_PRE_ENV(2),
        REL_DONE_ENV(3);

        private int value;

        private AppEnviron(int value) {
            this.value = value;
        }

        public int getValue() {
            return this.value;
        }

        public static AppEnviron of(int intValue) {

            switch (intValue) {

                case 1:
                    return DEV_TEST_ENV;

                case 2:
                    return REL_PRE_ENV;

                case 3:
                    return REL_DONE_ENV;

                default:
                    return REL_DONE_ENV;
            }
        }
    }

    public static void setEnviroment(int env) {

        switch (AppEnviron.of(env)) {

            case DEV_TEST_ENV:
                isDevelop = true;
                sServerApiUrl = sServerTestApiUrl;
                sLoanApiUrl = sLoanTestApiUrl;
                sBalanceApiUrl = sBalanceTestApiUrl;
                sBalanceH5ApiUrl = sBalanceH5TestApiUrl;
                sContractApiUri = sContractTestApiUri;
                sUpdateUrl = sUpdateTestUrl;
                sUpLoadingUrl = sUpLoadingDevDoneUri;
                depositH5Url = depositTestH5Url;
                break;

            case REL_PRE_ENV:
                isDevelop = false;
                sServerApiUrl = sServerPreApiUrl;
                sLoanApiUrl = sLoanPreApiUrl;
                sBalanceApiUrl = sBalancePreApiUrl;
                sBalanceH5ApiUrl = sBalanceH5PreApiUrl;
                sContractApiUri = sContractPreApiUri;
                sUpdateUrl = sUpdatePreUrl;
                sUpLoadingUrl = sUpLoadingPreRelUri;
                depositH5Url = depositPreH5Url;
                break;

            case REL_DONE_ENV:
                isDevelop = false;
                sServerApiUrl = sServerRelApiUrl;
                sLoanApiUrl = sLoanRelApiUrl;
                sBalanceApiUrl = sBalanceRelApiUrl;
                sBalanceH5ApiUrl = sBalanceH5RelApiUrl;
                sContractApiUri = sContractRelApiUri;
                sUpdateUrl = sUpdateRelUrl;
                sUpLoadingUrl = sUpLoadingRelDoneUri;
                depositH5Url = depositProH5Url;
                break;

            default:
                break;
        }
    }

    public static String getBussinessUrl(String string, String merchantNos, String merchantNames) {
        return sBalanceH5ApiUrl + string + "?merchantNos=" + merchantNos + "&merchantNames=" + merchantNames + "&dateType=1";
    }
}
